# AG 3.2 All in One Installer
# 
# Initial release by Ed Brannin, 31 Aug 2007 edbrannin@gmail.com
#Updated release by Nathan Gardiner, HIT Lab NZ, 20 March 2008 nathan.gardiner@hitlabnz.org
# 
#


# TODO: Make an option to allow non-silent installs of Python, etc.
# TODO: (optionally) ask for some setup information on installation, 
#       with defaults chosen from an .ini or some-such.
# TODO: Check for Java when installing TigerBoard
#       There's an example of this on the NSIS WIKI)
# TODO: Add "Setup Levels" 
#       like "Complete", "AG Only", "Extras Only", "Recommended"
# TODO: Add a "Start AccessGrid?" option to the end
# TODO: Add an HTML Readme that describes each package and how to use it.

Name "AG 3.2b1 Easy Installer v2.1"

# CHANGE THESE
!define VERSION "2.1"
!define COMPANY "Developed by RIT & HIT Lab NZ"
!define URL http://www.accessgrid.org

# Defines
!define REGKEY "SOFTWARE\$(^Name)"

# MUI defines
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico"
!define MUI_FINISHPAGE_NOAUTOCLOSE
#!define MUI_FINISHPAGE_RUN $INSTDIR\AGTk-3.1-final-Py-2.4.exe
#!define MUI_FINISHPAGE_RUN_PARAMETERS /s

# Included files
!include Sections.nsh
!include MUI.nsh

# Installer pages
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH

# Installer languages
!insertmacro MUI_LANGUAGE English

# Installer attributes
OutFile "AG3.2b1_easyinstaller_2.1.exe"
InstallDir $PROGRAMFILES\AGTk-3
CRCCheck on
XPStyle on
ShowInstDetails show
VIProductVersion 3.1.0.0
VIAddVersionKey ProductName AccessGrid
VIAddVersionKey ProductVersion "${VERSION}"
VIAddVersionKey CompanyName "${COMPANY}"
VIAddVersionKey CompanyWebsite "${URL}"
VIAddVersionKey FileVersion "2.1"
VIAddVersionKey FileDescription ""
VIAddVersionKey LegalCopyright ""

# Installer sections
SectionGroup !Python SecGrp_Python
    Section "!Python 2.4" Sec_Python24
        SetOutPath $INSTDIR
        SetOverwrite on
        File installers\python-2.4.4.msi
        ExecWait '"msiexec" /passive /i "$INSTDIR\python-2.4.4.msi" ALLUSERS=1'
        Delete $INSTDIR\python-2.4.4.msi
        WriteRegStr HKLM "${REGKEY}\Components" "Python 2.4" 1
    SectionEnd
    LangString DESC_Sec_Python ${LANG_ENGLISH} "Python is a programming language.  Required for AccessGrid.  www.python.org"    

    Section "!wxPython 2.6" Sec_wx26
        SetOutPath $INSTDIR
        SetOverwrite on
        File installers\wxPython2.6-win32-unicode-2.6.3.3-py24.exe
        ExecWait '$INSTDIR\wxPython2.6-win32-unicode-2.6.3.3-py24.exe /SILENT'
        Delete $INSTDIR\wxPython2.6-win32-unicode-2.6.3.3-py24.exe
        WriteRegStr HKLM "${REGKEY}\Components" "wxPython 2.6" 1
    SectionEnd
    LangString DESC_Sec_WxPython ${LANG_ENGLISH} "Python bindings for wxWidgets.  Required for AccessGrid.  www.wxpython.org"

    Section !pyWin32 Sec_pyWin32
        SetOutPath $INSTDIR
        SetOverwrite on
        File installers\pywin32-210.win32-py2.4.exe
        ExecWait '$INSTDIR\pywin32-210.win32-py2.4.exe /SILENT'
        Delete "$INSTDIR\pywin32-210.win32-py2.4.exe"
        WriteRegStr HKLM "${REGKEY}\Components" pyWin32 1
    SectionEnd
    LangString DESC_Sec_PyWin32 ${LANG_ENGLISH} "Python for Windows Extensions.  Required for AccessGrid.  http://starship.python.net/crew/mhammond/win32/"

SectionGroupEnd
LangString DESC_Sec_GrpPython ${LANG_ENGLISH} "These programs are required to run AccessGrid."


Section "!AccessGrid 3.2 beta1" Sec_AG31b1
    SetOutPath $INSTDIR
    SetOverwrite on
    File installers\AGTk-3.2-beta1-Py-2.4.exe
    ExecWait '$INSTDIR\AGTk-3.2-beta1-Py-2.4.exe /SILENT'
    Delete "$INSTDIR\AGTk-3.2-beta1-Py-2.4.exe"
    WriteRegStr HKLM "${REGKEY}\Components" "AccessGrid 3.2 beta1" 1
SectionEnd
LangString DESC_Sec_AccessGrid ${LANG_ENGLISH} "The AccessGrid 3 Toolkit.  http://www.accessgrid.org"


SectionGroup "AccessGrid add-ons" SecGrp_Services
   

    

    Section  "VPCScreen" Sec_VPCScreen
      SetOutPath "$INSTDIR\NodeServices"
	  SetOverwrite on
	  File installers\VPCScreenProducerService.zip
    SectionEnd
    LangString DESC_Sec_VPCScreen ${LANG_ENGLISH} "Version 0.2.1. VPCScreen can stream video of part of all of your screen.   http://sheriff.anu.edu.au/~rhys/VPCScreen/index.html"


	Section /o "VenueVNC" Sec_VenueVNC
		SetOutPath "$INSTDIR\SharedApplications"
		SetOverwrite on
		File installers\VenueVNC.agpkg3
		SetOutPath "$INSTDIR"
		ExecWait '"c:\Python24\python.exe" "$INSTDIR\bin\agpm3.py" -p "$INSTDIR\SharedApplications\VenueVNC.agpkg3"'

   SectionEnd
	LangString DESC_Sec_VenueVNC ${LANG_ENGLISH} "VenueVNC allows you to share your desktop"
	
	
   Section /o "Shared Desktop" Sec_SharedDesktop
   	SetOutPath "$INSTDIR\SharedApplications"
	SetOverwrite on
    File installers\SharedDesktop-v0.2.3_0.agpkg3
	SetOutPath "$INSTDIR"
	ExecWait '"c:\Python24\python.exe" "$INSTDIR\bin\agpm3.py" -p "$INSTDIR\SharedApplications\SharedDesktop-v0.2.3_0.agpkg3"'
    File installers\vnc-4_1_2-x86_win32.exe
    ExecWait '$INSTDIR\vnc-4_1_2-x86_win32.exe'
    Delete "$INSTDIR\vnc-4_1_2-x86_win32.exe"
   SectionEnd
    LangString DESC_Sec_SharedDesktop ${LANG_ENGLISH} "Version 2.3.0. Shared Desktop - Created by Todd Zimmerman"
	
#	Section /o "SharedOSG" Sec_SharedOSG
#   	SetOutPath "$INSTDIR\SharedApplications"
#	SetOverwrite on
#       File installers\SharedOSG_v2.agpkg3
#	SetOutPath "$INSTDIR"
#	ExecWait '"c:\Python24\python.exe" "$INSTDIR\bin\agpm3.py" -p "$INSTDIR\SharedApplications\SharedOSG_v2.agpkg3"'
#   SectionEnd
#    LangString DESC_Sec_SharedOSG ${LANG_ENGLISH} "Version 2.0. SharedOSG is an interactive 3D viewer - Developed by HIT Lab NZ & Rhys Hawkins"
    
    # With permission from Derek Piper, long as we show the license
    #   (so try not to do it silently)
    Section /o "AGVCR" Sec_AGVCR
        SetOutPath $INSTDIR
        SetOverwrite on
        File installers\AGVCR_2.2.1_Installer.exe
        ExecWait '$INSTDIR\AGVCR_2.2.1_Installer.exe'
        Delete "$INSTDIR\AGVCR_2.2.1_Installer.exe"
        WriteRegStr HKLM "${REGKEY}\Components" "AGVCR 2.2.1" 1
    SectionEnd
    LangString DESC_Sec_AGVCR ${LANG_ENGLISH} "Version 2.2.1. AccessGrid VCR lets you record and play back AccessGrid sessions.  http://iri.informatics.indiana.edu/~dcpiper/agvcr/"
    
    # With permission from Doc @ LSU
    # TODO Note that TigerBoard is in beta and will have a new release soon.
    Section /o "TigerBoard" Sec_Tigerboard
        SetOutPath "$INSTDIR\SharedApplications"
		SetOverwrite on
		File installers\TigerboardAG32_31oBeta.agpkg3
		SetOutPath "$INSTDIR"
		ExecWait '"c:\Python24\python.exe" "$INSTDIR\bin\agpm3.py" -p "$INSTDIR\SharedApplications\TigerboardAG32_31oBeta.agpkg3"'
        WriteRegStr HKLM "${REGKEY}\Components" TigerBoard 1
    SectionEnd
    LangString DESC_Sec_TigerBoard ${LANG_ENGLISH} "Version AG32_31oBeta. TigerBoard is a Shared Whiteboard for AG3.  Requires Java.  Made by Doc @ LSU.  http://lbrn.lsu.edu/portal/TigerBoardAG/"

	Section /o "H.264 Video Services" Sec_H264VideoServices

		WriteRegStr HKLM "${REGKEY}\Components" "H264VideoServices" 1

		SetOutPath "$INSTDIR\NodeServices"
		SetOverwrite on
		File installers\VideoProducerServiceH264.zip
		File installers\VideoConsumerServiceH264.zip   
    SectionEnd
    LangString DESC_Sec_H264VideoServices ${LANG_ENGLISH} "H.264 Video Consumer & Producer Services for AG 3.1"
	
	    # With permission from Sangwoo Han
    #   We just need to say "ExtendedVideo{Producer,Consumer}Services developed by GIST, Korea"
	Section /o "Extended Video Services" Sec_ExtendedVideo
		SetOutPath "$INSTDIR\NodeServices"
		SetOverwrite on
		File installers\ExtendedVideoConsumerService.zip
		File installers\ExtendedVideoProducerService.zip
		WriteRegStr HKLM "${REGKEY}\Components" "Extended Video Services" 1
	SectionEnd
	LangString DESC_Sec_ExtendedVideo ${LANG_ENGLISH} "Advanced Video service -- lets you see DV and HDV streams at 30+ Megabits/sec in.  Requires DirectX 9.0b or later and NTSC Camera.  Developed by GIST, Korea."

    
SectionGroupEnd
LangString DESC_Sec_GrpServices ${LANG_ENGLISH} "These services may make AccessGrid more useful for you."

!define PYTHON_PATH "\Python24"
!define PYTHON_EXE "${PYTHON_PATH}\pythonw.exe"
SectionGroup "Extra Tools & Settings" SecGrp_Tools

    Section "Shortcuts to International Venue Servers" Sec_Shortcut
        SetOutPath $INSTDIR\install
	  File installers\icons\USA.ico
	  File installers\icons\Australia.ico
	  File installers\icons\NZ.ico
	  File installers\icons\UK.ico
	  File installers\icons\Canada.ico
	  File installers\icons\France.ico
	  File installers\icons\south_korea.ico

	  SetOutPath $SMPROGRAMS
	  CreateDirectory "$SMPROGRAMS\Access Grid Toolkit 3\Access Grid Venue Servers"
        CreateShortcut "$SMPROGRAMS\Access Grid Toolkit 3\Access Grid Venue Servers\Argonne Venue.lnk" ${PYTHON_EXE} '"$INSTDIR\bin\VenueClient3.py" --url https://vv3.mcs.ano.gov:8000/Venues/default' "$INSTDIR\install\USA.ico"
	  CreateShortcut "$SMPROGRAMS\Access Grid Toolkit 3\Access Grid Venue Servers\NCSA Venue.lnk" ${PYTHON_EXE} '"$INSTDIR\bin\VenueClient3.py" --url https://venues.ncsa.uiuc.edu:8000/Venues/default' "$INSTDIR\install\USA.ico"
	  CreateShortcut "$SMPROGRAMS\Access Grid Toolkit 3\Access Grid Venue Servers\APAG Venue.lnk" ${PYTHON_EXE} '"$INSTDIR\bin\VenueClient3.py" --url https://vv3.ap-accessgrid.org:8000/Venues/default' "$INSTDIR\install\Australia.ico"
	  CreateShortcut "$SMPROGRAMS\Access Grid Toolkit 3\Access Grid Venue Servers\NZ Venue.lnk" ${PYTHON_EXE} '"$INSTDIR\bin\VenueClient3.py" --url https://agvenue.sges.auckland.ac.nz:8000/Venues/default' "$INSTDIR\install\NZ.ico"
	  CreateShortcut "$SMPROGRAMS\Access Grid Toolkit 3\Access Grid Venue Servers\UK Venue.lnk" ${PYTHON_EXE} '"$INSTDIR\bin\VenueClient3.py" --url https://sam.ag.manchester.ac.uk:8000/Venues/default' "$INSTDIR\install\UK.ico"
	  CreateShortcut "$SMPROGRAMS\Access Grid Toolkit 3\Access Grid Venue Servers\Canada Venue.lnk" ${PYTHON_EXE} '"$INSTDIR\bin\VenueClient3.py" --url https://venueserver.westgrid.ca:8000/Venues/default' "$INSTDIR\install\Canada.ico"
	  CreateShortcut "$SMPROGRAMS\Access Grid Toolkit 3\Access Grid Venue Servers\France Venue.lnk" ${PYTHON_EXE} '"$INSTDIR\bin\VenueClient3.py" --url https://accessgrid-venueserver.renater.fr:8000/Venues/default' "$INSTDIR\install\France.ico"
	  CreateShortcut "$SMPROGRAMS\Access Grid Toolkit 3\Access Grid Venue Servers\Korea Venue.lnk" ${PYTHON_EXE} '"$INSTDIR\bin\VenueClient3.py" --url https://vv3.accessgrid.kr:8000/Venues/default' "$INSTDIR\install\south_korea.ico"






	WriteRegStr HKLM "${REGKEY}\Components" "Shortcut to International Venue Servers" 1
    SectionEnd
    LangString DESC_Sec_Shortcut ${LANG_ENGLISH} "Starts AccessGrid and automatically connects to the selected International Venue Server shortcuts."

    
    Section  "Shortcut AccessGrid Logs" Sec_Shortcut_Logs
        SetOutPath $SMPROGRAMS
		CreateDirectory "$SMPROGRAMS\Access Grid Toolkit 3"
        CreateShortcut "$SMPROGRAMS\Access Grid Toolkit 3\AccessGrid Logs.lnk" "$APPDATA\AccessGrid3\Logs"
        WriteRegStr HKLM "${REGKEY}\Components" "Shortcut to AG Logs" 1
    SectionEnd
    LangString DESC_Sec_Logs ${LANG_ENGLISH} "The AccessGrid Log files -- you'll want this is if something goes wrong."
    
    Section "AGKiller Shortcut" Sec_Shortcut_Killer
        SetOutPath $INSTDIR
		CreateDirectory "$SMPROGRAMS\Access Grid Toolkit 3"
        File "installers\agkiller.py"
        CreateShortcut "$SMPROGRAMS\Access Grid Toolkit 3\AccessGrid Killer.lnk" "$INSTDIR\agkiller.py"
        WriteRegStr HKLM "${REGKEY}\Components" "AGKiller" 1
    SectionEnd
    LangString DESC_Sec_AGKiller ${LANG_ENGLISH} "A small script to kill AccessGrid and any of its services that may be misbehaving.  Only included as a convenience."

SectionGroupEnd
LangString DESC_Sec_Tools ${LANG_ENGLISH} "Various shortcuts we've found useful."

# Installer functions
Function .onInit
    InitPluginsDir
FunctionEnd

!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
    !insertmacro MUI_DESCRIPTION_TEXT ${Sec_Python24} $(DESC_Sec_Python)
    !insertmacro MUI_DESCRIPTION_TEXT ${Sec_wx26} $(DESC_Sec_WxPython)
    !insertmacro MUI_DESCRIPTION_TEXT ${Sec_pyWin32} $(DESC_Sec_PyWin32)
    !insertmacro MUI_DESCRIPTION_TEXT ${SecGrp_Python} $(DESC_Sec_GrpPython)

    !insertmacro MUI_DESCRIPTION_TEXT ${Sec_AG31b1} $(DESC_Sec_AccessGrid)
    !insertmacro MUI_DESCRIPTION_TEXT ${Sec_VenueVNC} $(DESC_Sec_VenueVNC)
    !insertmacro MUI_DESCRIPTION_TEXT ${Sec_VPCScreen} $(DESC_Sec_VPCScreen)
    !insertmacro MUI_DESCRIPTION_TEXT ${Sec_H264VideoServices} $(DESC_Sec_H264VideoServices)
    !insertmacro MUI_DESCRIPTION_TEXT ${Sec_SharedDesktop} $(DESC_Sec_SharedDesktop)
#	!insertmacro MUI_DESCRIPTION_TEXT ${Sec_SharedOSG} $(DESC_Sec_SharedOSG)
    !insertmacro MUI_DESCRIPTION_TEXT ${Sec_Tigerboard} $(DESC_Sec_TigerBoard)
    !insertmacro MUI_DESCRIPTION_TEXT ${Sec_AGVCR} $(DESC_Sec_AGVCR)
    !insertmacro MUI_DESCRIPTION_TEXT ${SecGrp_Services} $(DESC_Sec_GrpServices)
    !insertmacro MUI_DESCRIPTION_TEXT ${Sec_ExtendedVideo} $(DESC_Sec_ExtendedVideo)
    !insertmacro MUI_DESCRIPTION_TEXT ${Sec_Shortcut} $(DESC_Sec_Shortcut)
    !insertmacro MUI_DESCRIPTION_TEXT ${Sec_Shortcut_Logs} $(DESC_Sec_Logs)
    !insertmacro MUI_DESCRIPTION_TEXT ${Sec_Shortcut_Killer} $(DESC_Sec_AGKiller)
    !insertmacro MUI_DESCRIPTION_TEXT ${SecGrp_Tools} $(DESC_Sec_Tools)
!insertmacro MUI_FUNCTION_DESCRIPTION_END
